<?php $categories = $this->categories;

//Add category to combobox, start with level = 1 and parentID = 0
function AddCategory($cats, $level, $parentID)
{
	foreach($cats as $cat)
	{
		//echo "<br> for";
		if($cat['parentid']==$parentID && $cat['level']==$level)
		{
			$name = "<option>";
			for($i = 0; $i<$level;$i++)
			{
				$name.="&nbsp&nbsp&nbsp";
			}
			$name.="|_&nbsp";
			$name.=$cat['name'];
			$name.="</option>";
			echo $name;
			AddCategory($cats, $level+1, $cat['id']);
		}
	}
}


?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>New article</title>

<script src="<?php echo $this->baseUrl();?>/jquery/jqueryui/jquery-1.6.4.min.js"></script>
<script src="<?php echo $this->baseUrl();?>/jquery/jqueryui/jquery-ui-1.8.16.custom.min.js"></script>
<script src="<?php echo $this->baseUrl();?>/jquery/jqueryui/jquery-ui-timepicker-addon.js"></script>
<!--  <script src="<?php echo $this->baseUrl();?>/jquery/ui/jquery.ui.datepicker.js"></script>
<script type="text/javascript" src="jqueryui/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="jqueryui/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="jqueryui/jquery-ui-timepicker-addon.js"></script>  -->
<link rel="stylesheet" href="<?php echo $this->baseUrl();?>/jquery/jqueryui/jquery-ui-1.8.16.custom.css"/>


<script type="text/javascript">

function OnSaveClick(form)
{
    getContentToHiddenInput();
	form.action='save';
    form.submit();
    return true;
}

function OnChooseClicked()
{
	window.open("../user/choose", 'mypopup' , 'width=400, height=300, toolbar=no, scrollbars=no, resizable=no, status=no, toolbar=no, menubar=no, location=no');
}

</script>

<script>
$(function()
{
	$("#tCreatedDate").datetimepicker({timeFormat: 'hh:mm:ss', dateFormat: 'yy-mm-dd'});
});

$(function()
{
	$("#tStartPublishing").datetimepicker({timeFormat: 'hh:mm:ss', dateFormat: 'yy-mm-dd'});
});

$(function()
{
	$("#tFinishPublishing").datetimepicker({timeFormat: 'hh:mm:ss', dateFormat: 'yy-mm-dd'});
});

</script>

</head>



<body>
<form name="myform" method="post">
<table width="100%" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td width="50%"><strong>Article manager : Add new article</strong></td>
    <td width="50%" align="right"><input type="submit" name="bSave" id="bSave" value="Save" onclick="OnSaveClick(this.form)"/>
      <!-- <input type="submit" name="bSaveClose" id="bSaveClose" value="Save &amp; close" onclick="OnSaveCloseClick()"/>
      <input type="submit" name="bSaveNew" id="bSaveNew" value="Save &amp; new" onclick="OnSaveNewClick()"/> -->
      <input type="submit" name="bCancel" id="bCancel" value="Cancel" onclick="OnCancelClick()"/></td>
  </tr>
  <tr>
    <td rowspan="3"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>Title*</td>
        <td><label for="tTitle"></label>
          <input type="text" name="tTitle" id="tTitle" /></td>
      </tr>
      <tr>
        <td>Alias</td>
        <td><label for="tAlias"></label>
          <input type="text" name="tAlias" id="tAlias" /></td>
      </tr>
      <tr>
        <td>Category*</td>
        <td><label for="sCategory"></label>
          <select name="sCategory" id="sCategory">
          	<?php AddCategory($categories, 1, 0);?>
          </select></td>
      </tr>
      <tr>
        <td>State          </td>
        <td><label for="sState"></label>
          <select name="sState" id="sState">
            <option>Published</option>
            <option>Unpublished</option>
            <option>Archived</option>
            <option>Trashed</option>
          </select></td>
      </tr>
      <tr>
        <td>Access</td>
        <td><label for="sAccess"></label>
          <select name="sAccess" id="sAccess">
            <option>Public</option>
            <option>Registered</option>
            <option>Special</option>
          </select></td>
      </tr>
      <tr>
        <td>ID</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td colspan="2">
			<p>Article :</p>
          	<?php include_once('RichTextEditor/editor.phtml'); ?></td>
        </tr>
      <tr>
        <td colspan="2">&nbsp;</td>
        </tr>
    </table></td>
    <td>Publishing Option
<table width="200" border="0">
  <tr>
        <td>Created by</td>
        <td><label for="tCreatedBy"></label>
          <input type="text" name="tCreatedBy" id="tCreatedBy" /></td>
      </tr>
      <tr>
        <td colspan="2"><input type="button" name="bSelectUser" id="bSelectUser" value="Select user" onclick="OnChooseClicked()"/></td>
        </tr>
      <tr>
        <td>Created date</td>
        <td><label for="tCreatedDate"></label>
          <input type="text" name="tCreatedDate" id="tCreatedDate" /></td>
      </tr>
      <tr>
        <td>Start publishing</td>
        <td><label for="tStartPublishing"></label>
          <input type="text" name="tStartPublishing" id="tStartPublishing" /></td>
      </tr>
      <tr>
        <td>Finish publishing</td>
        <td><label for="tFinishPublishing"></label>
          <input type="text" name="tFinishPublishing" id="tFinishPublishing" /></td>
      </tr>
  </table></td>
  </tr>
  <tr>
    <td height="150"><p>Metadata Option</p>
      <p>Metadata description:
        <label for="tMetaDes"></label>
        <textarea name="tMetaDes" id="tMetaDes" cols="45" rows="5"></textarea>
      </p>
      <p>Metadata keyword :
        <label for="tMetaKeyword"></label>
        <textarea name="tMetaKeyword" id="tMetaKeyword" cols="45" rows="5"></textarea>
      </p></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
</form>
</body>
</html>
